<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <title>Document</title>
        <style>
        *{
            margin: 0px;
            padding: 0px;
            list-style:none;
        }
        div{
            widows: 520px;
            height: 280px;
            margin: 0px auto;
        }
        ul{
            width: 9999px;
            position: relative;
            left: 0px;
        }
        ul li{
            float: left;
        }
        ol{
            position: absolute;
            bottom:0px;
            left: 50%;
            transform:translateX(-50%);
        }
        ol li{
            margin: 0px 4px;
            width: 10px;
            height: 10px;
            background:red;
            float: left;
        }
        span{
        position: absolute;
        top:50%;
        transform: translateY(-50%);
        background:lime;
        cursor: pointer;
        }
        .left{
            left:10px;
        }
        .right{
            right:10px
        }
        
        
        
        
        
        
        
        
        
        
        
        
        
        </style>






    </head>
    <body>
        <div id="wrap">
            <ul id="box">
                <li><img src="images/pic1.jpg" alt=""></li>
                <li><img src="images/pic2.jpg" alt=""></li>
                <li><img src="images/pic3.png" alt=""></li>
                <li><img src="images/pic4.jpg" alt=""></li>
            </ul>
            <ol>
                <li></li>
                <li></li>
                <li></li>
                <li></li>
            </ol>
            <span class="left">左</span>
            <span class="right">右</spaan>
        </div>
        <script>
        var num=0;
        var box=document.getElementById('box');
        var wrap=document.getElementById('wrap');
        var timer;
        timer=setInterval(function(){
            num--;
            if(num<-3){
                num=0
            }
            box.style.left=520*num+'px';
        },1000)
        wrap.onmouseenter=function(){
            clearInterval(timer)
        }
        wrap.onmouseleave=function(){
            timer=setInterval(function(){
            num--;
            if(num<-3){
                num=0
            }
        box.style.left=520*num+'px';},1000)
        }
        
        
        </script>
    </body>
</html>